from rest_framework.generics import UpdateAPIView
from rest_framework.viewsets import ModelViewSet
from apps.meiduo_admin.serializers.order import *
from apps.meiduo_admin.utils import PageNum


class OrderModelView(ModelViewSet):
    """订单管理"""
    serializer_class = OrderModelSerializer
    pagination_class = PageNum

    def get_queryset(self):
        order_id = self.request.query_params.get('keyword')
        if order_id:
            return OrderInfo.objects.filter(order_id=order_id)
        return OrderInfo.objects.all()


class OrderStatusView(UpdateAPIView):
    """修改订单状态"""
    queryset = OrderInfo.objects.all()
    serializer_class = OrderSerializer


